package com.bawei.day12_broadcastrecevier;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;

// 广播接受者:1。自定义类继承BroadCastRecevier，重写onRecevie
public class MyRecevicer extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();//获得频道
        if("com.bawei.yaotianxue".equals(action)){
            Bundle bundle = intent.getBundleExtra("data");
            String message = bundle.getString("message");
            Toast.makeText(context, ""+message, Toast.LENGTH_SHORT).show();
        }else if("com.bawei.yaotianxue2".equals(action)){
            Bundle bundle = intent.getBundleExtra("data");
            String message = bundle.getString("message");
            Toast.makeText(context, ""+message, Toast.LENGTH_SHORT).show();
        }
    }
}